home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / Cosmic Defender.swf / scripts / frame_23 / PlaceObject2_287_17 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Encoding:
Text File  |  2006-06-13  |  3.1 KB  |  110 lines

  1. onClipEvent(enterFrame){
  2.    if(!_root.paused && _root.sound_on)
  3.    {
  4.       this.turbine.setVolume(Math.abs(_root.ship_speed * 2) + 4);
  5.    }
  6.    else
  7.    {
  8.       this.turbine.setVolume(0);
  9.    }
  10.    if(_root.player_on && !_root.hyperspace && !_root.paused)
  11.    {
  12.       this._visible = true;
  13.       if(Key.isDown(68))
  14.       {
  15.          if(_root.sound_on)
  16.          {
  17.             _root.hyperjump.start(0,1);
  18.          }
  19.          this.hyper_dx = Math.random() * 500 + 700;
  20.          this.hyper_dx = Math.random() >= 0.5 ? - this.hyper_dx : this.hyper_dx;
  21.          _root.hyper_x = _root.ToNewX(_root.ship_x,this.hyper_dx);
  22.          _root.hyperspace = true;
  23.       }
  24.       if(Key.isDown(83) && _root.globalBang == 0 && _root.smartbombs > 0)
  25.       {
  26.          _root.globalBang = 13;
  27.          if(_root.sound_on)
  28.          {
  29.             _root.smart_sfx.start(0,1);
  30.          }
  31.          _root.smartbombs -= 1;
  32.          _root.bombs.gotoAndStop(_root.smartbombs + 1);
  33.          i = 1;
  34.          while(i < 16)
  35.          {
  36.             this.ship = eval("_root.ship_" + i);
  37.             if(this.ship && this.ship._x < 550)
  38.             {
  39.                this.ship.Destroy(true);
  40.                _root.EnemyAr[i] = false;
  41.             }
  42.             i++;
  43.          }
  44.       }
  45.       if((Key.isDown(65) || Key.isDown(32)) && this.glow._currentframe == 1)
  46.       {
  47.          this.glow.play();
  48.          if(_root.sound_on)
  49.          {
  50.             _root.pl_shot_sfx.start(0,1);
  51.          }
  52.          _root.attachMovie("player_shot","shot_" + this.bullets,this.bullets + 3000);
  53.          this.bullets += 1;
  54.          if(this.bullets > 9)
  55.          {
  56.             this.bullets = 0;
  57.          }
  58.       }
  59.       this.flame._alpha = Math.abs(_root.ship_speed) * 5;
  60.       this.flame._xscale = Math.abs(_root.ship_speed) * 8;
  61.       _root.ship_x += _root.ship_speed;
  62.       _root.ship_speed *= 0.98;
  63.       this.to_x = (- _root.ship_speed) * 10 + 275;
  64.       this.x = _root.ship_x + 30 + this.to_x;
  65.       if(_root.ship_x < 0)
  66.       {
  67.          _root.temp_dx = _root.x_dimension % _root.ship_speed;
  68.          _root.ship_x = _root.x_dimension - _root.temp_dx;
  69.       }
  70.       if(_root.ship_x > _root.x_dimension)
  71.       {
  72.          _root.temp_dx = _root.x_dimension % _root.ship_speed;
  73.          _root.ship_x = _root.temp_dx;
  74.       }
  75.       if(Key.isDown(37))
  76.       {
  77.          _root.ship_speed -= 2;
  78.          this._xscale = -100;
  79.       }
  80.       if(Key.isDown(39))
  81.       {
  82.          _root.ship_speed += 2;
  83.          this._xscale = 100;
  84.       }
  85.       if(_root.ship_speed > _root.max_speed)
  86.       {
  87.          _root.ship_speed = _root.max_speed;
  88.       }
  89.       if(_root.ship_speed < - _root.max_speed)
  90.       {
  91.          _root.ship_speed = - _root.max_speed;
  92.       }
  93.       this.to_y += 12 * (Key.isDown(40) - Key.isDown(38));
  94.       if(this.to_y > 370)
  95.       {
  96.          this.to_y = 370;
  97.       }
  98.       if(this.to_y < 80)
  99.       {
  100.          this.to_y = 80;
  101.       }
  102.       this._y -= (this._y - this.to_y) / 3;
  103.       this._x -= (this._x - this.to_x) / 7;
  104.    }
  105.    else if(!_root.hyperspace && !_root.paused)
  106.    {
  107.       this._visible = false;
  108.    }
  109. }
  110.